rails mysql redis 的开发环境
首先构建自己的镜像
Dockerfile.development
FROM ruby:2.3.4-slim
RUN apt-get update && apt-get install -y \
build-essential \
nodejs \
libmysqlclient-dev
RUN mkdir -p /app
WORKDIR /app
COPY Gemfile Gemfile.lock /app/
RUN gem install bundler && bundle install --jobs 20 --retry 5
COPY . /app
EXPOSE 4000
ENTRYPOINT ["bundle", "exec"]
CMD ["rails", "server", "-b", "0.0.0.0", "-p", "4000"]
docker-compose.yml 配置
使用mysql redis,数据库配置里host要写成 mysql, redis
version: '3'
services:
mysql:
image: mysql:5.7.17
command: --sql-mode=""
restart: always
volumes:
- ./mysql_data/:/var/lib/mysql
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: shiji_development
redis:
image: redis
command: redis-server
volumes:
- ./redis_data:/data
ports:
- 6379:6379
web:
build:
context: .
dockerfile: Dockerfile.development
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 4000 -b '0.0.0.0'"
stdin_open: true
tty: true
volumes:
- .:/app
ports:
- "4000:4000"
depends_on:
- mysql
- redis
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。